package com.wooophone.webapp.mpyeah.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.wooophone.common.util.HtmlRegexpUtil;
import com.wooophone.common.web.action.BaseAction;
import com.wooophone.mpyeah.biz.BrandCommentReplyBiz;
import com.wooophone.mpyeah.entity.BrandCommentReply;

public class ReplyAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	BrandCommentReply reply;

	@Autowired
	private BrandCommentReplyBiz brandCommentReplyBiz;

	public String save() {
		try {
			regexp(reply);
			brandCommentReplyBiz.save(reply);
			if (reply.getId() != null) {
				return ajax(Status.success);
			} else {
				return ajax(Status.error);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return ajax(Status.error);
	}
	
	/**
	 * 去除危险标签
	 * 
	 * @param comment
	 */
	private void regexp(BrandCommentReply reply) {
		if (reply != null) {
			if (reply.getContent() != null)
				reply.setContent(HtmlRegexpUtil.filterHtml(reply
						.getContent()));
		}
	}

	public BrandCommentReply getReply() {
		return reply;
	}

	public void setReply(BrandCommentReply reply) {
		this.reply = reply;
	}

	public void setBrandCommentReplyBiz(
			BrandCommentReplyBiz brandCommentReplyBiz) {
		this.brandCommentReplyBiz = brandCommentReplyBiz;
	}
}
